﻿@model IMall.Web.Models.ViewModels.ListModel
@{
    ViewBag.Title = "商品列表";
}
<div class="row clearfix">
    <ul class="breadcrumb" style="margin:0;background-color:white">
        <li>
            <a href="~/Home">首页</a>
        </li>
        <li class="active">
            @(string.IsNullOrWhiteSpace(Model.KeyWord)? "所有商品" : Model.KeyWord)
        </li>
    </ul>
</div>
<nav aria-label="Page navigation">
    <ul class="pagination">
        <li>
            <a href="@(Model.Page != 1 ? "/Home/List?keyword=" + Model.KeyWord + "&page=1" : "#")" aria-label="Previous">
                <span aria-hidden="true">Pre</span>
            </a>
        </li>
        <li>
            <a href="@(Model.Page > 1 ? "/Home/List?keyword=" + Model.KeyWord + "&page=" + (Model.Page - 1) : "#")" aria-label="Previous">
                <span aria-hidden="true">&laquo;</span>
            </a>
        </li>
        @for (int i = 1; i <= Model.PageNumber; i++)
        {
            <li><a href="@("/Home/List?keyword=" + Model.KeyWord + "&page=" + i)">@i</a></li>
        }
        <li>
            <a href="@(Model.Page < Model.PageNumber ? "/Home/List?keyword=" + Model.KeyWord + "&page=" + (Model.Page + 1) : "#")" aria-label="Next">
                <span aria-hidden="true">&raquo;</span>
            </a>
        </li>
        <li>
            <a href="@(Model.Page != Model.PageNumber ? "/Home/List?keyword=" + Model.KeyWord + "&page=" + Model.PageNumber : "#")" aria-label="Next">
                <span aria-hidden="true">End</span>
            </a>
        </li>
    </ul>
</nav>

<div class="row clearfix">
    <div class="col-md-12 column">
        <div class="row">
            @foreach (var m in Model.List)
            {
                <div class="col-md-3" style="margin-top:30px;">
                    <a href="~/Home/Details/@(m.Id)">
                        <div class="thumbnail">
                            <img src="~/Content/List/@(m.Icon)" />
                            <div class="caption">
                                <h3 style="text-align:center">
                                    @m.Price
                                </h3>
                                <p>
                                    @m.Name
                                </p>
                            </div>
                        </div>
                    </a>
                </div>
            }
        </div>
    </div>
</div>

<nav aria-label="Page navigation">
    <ul class="pagination">
        <li>
            <a href="@(Model.Page > 1 ? "~/Home/List?keyword=" + Model.KeyWord + "&page=" + (Model.Page - 1) : "#")" aria-label="Previous">
                <span aria-hidden="true">&laquo;</span>
            </a>
        </li>
        @for (int i = 1; i <= Model.PageNumber; i++)
        {
            <li><a href="@("~/Home/List?keyword=" + Model.KeyWord + "&page=" + i)">@i</a></li>
        }
        <li>
            <a href="@(Model.Page < Model.PageNumber ? "~/Home/List?keyword=" + Model.KeyWord + "&page=" + (Model.Page + 1) : "#")" aria-label="Next">
                <span aria-hidden="true">&raquo;</span>
            </a>
        </li>
    </ul>
</nav>
